package com.example.demo.service.Impl;

import com.example.demo.mapper.Docmapper;
import com.example.demo.pojo.Doc;
import com.example.demo.pojo.PageBean;
import com.example.demo.service.Docservice;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class Docserviceimpl implements Docservice {
    @Autowired
    Docmapper docmapper;
    public List<Doc>queryAll(){
       List<Doc> Dlist=docmapper.queryAll();
       return Dlist;
    }
    public List<Doc>queryName(String name){
        return docmapper.queryName(name);
    }
    public void delete(String doc_id){
        docmapper.delete(doc_id);

    }
    public void insert(Doc doc){
        docmapper.insert(doc);
    }
    public void update(Doc doc){
        docmapper.update(doc);
    }
    public PageBean page(Integer page,Integer pageSize){
        PageHelper.startPage(page,pageSize);
        List<Doc> docList=docmapper.queryAll();
        Page<Doc> p= (Page<Doc>) docList;
        PageBean pageBean =new PageBean(p.getTotal(),p.getResult());
        return  pageBean;
    }




}
